package com.rain.fdfs.controller;

import com.rain.fdfs.bean.Student;
import com.rain.fdfs.util.FastDfsUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author: ShanGui
 * @create: 2021-08-15 22:51
 */
@RestController
@RequestMapping("/fdfs")
public class FastDFSController {
    @Autowired
    private FastDfsUtil fastDfsUtil;

    @PostMapping("/upload")
    public String upload(@RequestParam MultipartFile file1,@RequestParam MultipartFile file2, Student student) throws IOException {
        String s1 = fastDfsUtil.uploadFile(file1);
        String s2 = fastDfsUtil.uploadFile(file2);
        System.out.println("s1 = " + s1);
        System.out.println("s2 = " + s2);
        System.out.println("student = " + student);
        return s1 + "---" + s2;
    }
}
